//修改密码操作
$(document).off("click", "#showIndexUpdatePW").on("click", "#showIndexUpdatePW", function () {
    var showContent = $('#showIndexUpdatePWContent').html();
    $('#showIndexUpdatePWContent').html("");
    layer.open({
        type: 1,
        id: 'showLayui',
        title: '修改密码',
        content: showContent, //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
        area: '600px',
        btn: ['确定', '取消'],
        btnAlign: 'c',
        success: function (layero, index) {//打开层之后可执行的回调
            layui.use(['form', 'layer'], function () {
                var form = layui.form;
                var layer = layui.layer;

                form.render();  //重新渲染表单
            });
        },
        yes: function (index, layero) { //确定按钮
            var con = {};
            //con.userId = userId.id;
            con.sysOldPWInp = $("#sysOldPWInp").val();
            con.sysNewPWInp = $("#sysNewPWInp").val();
            con.sysConPW = $("#sysConfirmPWInp").val();

            var msgArr = ["原密码不能为空", "新密码不能为空", "确认密码不能为空"];  //提示语集合
            var clsArr = ["#sysOldPWInp", "#sysNewPWInp", "#sysConfirmPWInp"];  //id集合
            var validateFlag = until.validate(msgArr, clsArr); //非空验证 需要引入工具js文件until
            if (validateFlag) {
                layer.msg(validateFlag, { anim: 6, time: 1500 });
                return;
            };
            var numFlag = checkInpNum(clsArr);
            //检查长度是否小于6
            if (numFlag) {
                layer.msg(numFlag, { anim: 6, time: 1500 });
                return;
            };

            $.ajax({
                url: contextPath + "/account/updatePassWord",
                dataType: 'json',
                type: 'post',
                async: false,
                data: con,
                complete: function (XHR, TS) {
                    var returnObj = eval('(' + XHR.responseText + ')');
                    if (returnObj.code != 200) {
                        layer.msg(returnObj.msg, { anim: 6, time: 1500 });
                    } else {
                        layer.msg(returnObj.msg, { icon: 1, time: 1500 });
                        layer.close(index);
                        window.setTimeout(function () {
                            window.location.href = contextPath + "/logOut";
                        }, 1000);

                    }
                }
            });

        },
        end: function () { //只要层被销毁了，end都会执行
            $('#showIndexUpdatePWContent').html(showContent);
        }

    });
});